/**
 * Created by huzhihui on 2017/9/20.
 */
import {requestHtml} from "../../../utils/request";
import introUrl from "./index.txt";

export default {
    namespace: 'configuration',
    state: {
        initStatus: false,
        configurationHtml: '<h1>记载中</h1>'
    },
    reducers: {
        'updateConfigurationHtml'(state, {payload: value}){
            return {
                initStatus: true,
                configurationHtml: value
            }
        }
    },
    effects: {
        *getConfigurationHtml({payload}, {select, call, put}){
            const initStatus = yield select(state => state.configuration.initStatus)
            if (initStatus == true) {
                return;
            }
            const result = yield call(requestHtml, introUrl);
            yield put({
                type: 'updateConfigurationHtml',
                payload: result.data
            })
        }
    }
}